package com.briup.mt.web.controller;


import com.briup.mt.bean.BaseUser;
import com.briup.mt.service.IBaseUserService;
import com.briup.mt.utils.Message;
import com.briup.mt.utils.MessageUtil;

import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Validated
@RequestMapping("/baseUser")
public class BaseUserController {

    @Autowired
    private IBaseUserService baseUserService;

    @GetMapping("query")
    public Message query(String realname,String gender){
        List<BaseUser> list = baseUserService.query(realname,gender);
        return MessageUtil.success(list);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(BaseUser baseUser){
        baseUserService.saveOrUpdate(baseUser);
        return MessageUtil.success(baseUser);

    }

    @DeleteMapping("deleteById")
    public Message deleteById(Long id){
        baseUserService.deleteById(id);
        return MessageUtil.success("操作成功");
    }

}
